]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
shell/window-tracker: Disassociate windows on shutdown
authorJonas Ådahl <jadahl@gmail.com>
Thu, 24 Nov 2022 15:27:29 +0000 (16:27 +0100)
committerJonas Ådahl <jadahl@gmail.com>
Fri, 25 Nov 2022 21:09:37 +0000 (22:09 +0100)
This avoids trying to deal with handling windows being unmanaged one by
one after we destroyed the ShellGlobal.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1349>

src/shell-window-tracker.c

index 8c3de6f32a205e140aa909d532ba81d41860b511..991613ea3f00fb0fb2d21d4e5d36bb24d6ab62dc 100644 (file)
@@ -631,6 +631,23 @@ on_startup_sequence_changed (MetaStartupNotification *sn,
   g_signal_emit (G_OBJECT (self), signals[STARTUP_SEQUENCE_CHANGED], 0, sequence);
 }
 
+static void
+on_shutdown (ShellGlobal        *shell_global,
+             ShellWindowTracker *tracker)
+{
+  g_autoptr (GList) windows;
+  GList *l;
+
+  windows = g_hash_table_get_keys (tracker->window_to_app);
+  for (l = windows; l; l = l->next)
+    {
+      MetaWindow *window = l->data;
+
+      disassociate_window (tracker, window);
+    }
+  g_assert (g_hash_table_size (tracker->window_to_app) == 0);
+}
+
 static void
 shell_window_tracker_init (ShellWindowTracker *self)
 {
@@ -646,6 +663,9 @@ shell_window_tracker_init (ShellWindowTracker *self)
 
   load_initial_windows (self);
   init_window_tracking (self);
+
+  g_signal_connect (shell_global_get (),
+                    "shutdown", G_CALLBACK (on_shutdown), self);
 }
 
 static void